﻿using System;
using System.Text;

namespace AutoDb {
	/// <summary>
	/// 
	/// </summary>
	sealed class FileLogWriter : ILogWriter {
		/// <summary>
		/// 
		/// </summary>
		private System.IO.StreamWriter InnerWriter { get; set; }

		/// <summary>
		/// 
		/// </summary>
		public LogLevel Level {
			get;
			set;
		}

		/// <summary>
		/// 
		/// </summary>
		/// <param name="level"></param>
		/// <param name="s"></param>
		public void Write(LogLevel level, string s) {
			InnerWriter.Write(s);
		}

		/// <summary>
		/// 
		/// </summary>
		/// <param name="level"></param>
		public void WriteLine(LogLevel level) {
			InnerWriter.WriteLine();
			InnerWriter.Flush();
		}

		/// <summary>
		/// 
		/// </summary>
		public void Close() {
			InnerWriter.Flush();
			InnerWriter.Close();
		}

		/// <summary>
		/// 
		/// </summary>
		/// <param name="fileName"></param>
		public FileLogWriter(string fileName) {
			InnerWriter = new System.IO.StreamWriter(fileName, false, Encoding.UTF8);
		}
	} // end of FileLogWriter.
}
